import time
import pytest
from Page.page_login import Login
from Tools.tools import DriverTools, read_json, GetLog
from config import BASE_URL
from script import log


class TestLogin():
    def setup_method(self):
        driver = DriverTools.get_driver()
        driver.get(BASE_URL + "/common/member/login")
        self.login = Login(driver)

    def teardown_method(self):
        DriverTools.close_driver()

    arg_nums = "phone,password,expect,img"

    @pytest.mark.parametrize(arg_nums, read_json("login_data.json"))
    def test_login_success_all(self, phone, password, expect, img):
        self.login.login_succeses(phone, password)
        time.sleep(2)
        if phone == "18738142070":
            result2 = self.login.assert_login()
        else:
            result2 = self.login.assert_login_fail()
        log.info(f"执行的结果：{result2}")
        assert expect in result2
        self.login.get_shot(img)
